﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;

namespace WhatIsMyIP
{
    public partial class frmMain : Form
    {
        public frmMain()
        {
            InitializeComponent();
        }

        private void frmMain_Load(object sender, EventArgs e)
        {
            RefreshData();
        }

        private void pictureBox_Click(object sender, EventArgs e)
        {
            RefreshData();
        }

        private void menuItemRefresh_Click(object sender, EventArgs e)
        {
            RefreshData();
        }

        private void RefreshData()
        {
            string deviceName = System.Net.Dns.GetHostName();

            textBoxDeviceName.Text = deviceName;

            IPAddress[] addresses = Dns.GetHostEntry(deviceName).AddressList;

            comboBoxDeviceIP.Items.Clear();
            for (int i = 0; i < addresses.Length; i++)
                comboBoxDeviceIP.Items.Add(addresses[i].ToString());

            if (comboBoxDeviceIP.Items.Count > 0)
                comboBoxDeviceIP.SelectedIndex = 0;
        }

        private void menuItemAbout_Click(object sender, EventArgs e)
        {
            frmAbout aboutForm = new frmAbout();
            aboutForm.ShowDialog();
        }
    }
}